var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2ADManager = require("ADManager");
var $2pvzChannel = require("pvzChannel");
var $2BundleManager = require("BundleManager");
var $2DataManager = require("DataManager");
var $2PlantMgr = require("PlantMgr");
var $2UserDataManager = require("UserDataManager");
var $2KDefine = require("KDefine");
var $2kc = require("kc");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_Card = /* */function (_cc$Component10) {
  babel_inherits(p, _cc$Component10);
  var _super12 = babel_createSuper(p);
  function p() {
    var _this35;
    babel_classCallCheck(this, p);
    _this35 = _super12.apply(this, arguments);
    _this35.bg = null;
    _this35.icon = null;
    _this35.mask = null;
    _this35.costLabel = null;
    _this35.costMask = null;
    _this35.new = null;
    _this35.lock = true;
    _this35.id = 0;
    _this35.desc = null;
    _this35.name = null;
    _this35.level = 0;
    _this35.isLock = false;
    _this35.canAddGoldByVideo = false;
    return _this35;
  }
  babel_createClass(p, [{
    key: "onLoad",
    value: function onLoad() {
      var _this36 = this;
      $2pvzChannel.pvzChannel.instance().channel.indexOf("wx") >= 0 && this.costMask.on(cc.Node.EventType.TOUCH_START, function () {
        $2kc.default.log("sun不足弹窗", _this36.canAddGoldByVideo);
        _this36.canAddGoldByVideo && $2kc.default.sendMsg($2KDefine.Msg.showNoSunUI);
      }, this);
    }
  }, {
    key: "init",
    value: function init(e) {
      this.id = e;
      this.desc = $2PlantMgr.default.instance().getPlant(e).desc;
      this.name = $2PlantMgr.default.instance().getPlant(e).name;
      this.cd = $2PlantMgr.default.instance().getPlant(e).cd[$2UserDataManager.default.instance.getPlantLevel(this.id) - 1][1];
      $2ADManager.default.instance.isTest && $2DataManager.default.instance.noCD && (this.cd = 0);
      if ($2UserDataManager.default.instance.plantLock.includes(this.id) || $2DataManager.default.instance.tryPlant.includes(e)) {
        this.node.getChildByName("Lock").active = false;
        this.lock = false;
      } else {
        this.node.getChildByName("Lock").active = true;
        this.lock = true;
      }
      var t = this.icon.getComponent(cc.Sprite);
      t.spriteFrame = $2BundleManager.default.instance.getBundleRes("BundleTexture", "PlantIcon/p_" + e, cc.SpriteFrame);
      t.sizeMode = cc.Sprite.SizeMode.RAW;
      t.trim = false;
      this.costLabel.string = "" + $2PlantMgr.default.instance().getPlant(e).cost[$2UserDataManager.default.instance.getPlantLevel(e) - 1][1];
      this.rare = $2PlantMgr.default.instance().getPlant(e).rare;
      this.bg.getComponent(cc.Sprite).spriteFrame = $2BundleManager.default.instance.getBundleRes("BundleTexture", "ui/card_bg_" + this.rare, cc.SpriteFrame);
      this.mask.active = false;
      if ($2pvzChannel.pvzChannel.instance().channel.indexOf("wx") >= 0) {
        this.canAddGoldByVideo = true;
      } else {
        this.canAddGoldByVideo = false;
      }
      return this;
    }
  }, {
    key: "showCD",
    value: function showCD() {
      var _this37 = this;
      var e;
      this.mask.active = true;
      this.mask.getComponent(cc.Sprite).fillRange = 1;
      e = $2DataManager.default.instance.noCD ? 0 : this.cd;
      cc.tween(this.mask.getComponent(cc.Sprite)).to(e, {
        fillRange: 0
      }).call(function () {
        _this37.mask.active = false;
      }).start();
    }
  }, {
    key: "setId",
    value: function setId(e) {
      this.id = e;
      var t = $2BundleManager.default.instance.getBundleRes("BundleTexture", "PlantIcon/p_" + e, cc.SpriteFrame);
      var a = this.icon.getComponent(cc.Sprite);
      a.sizeMode = cc.Sprite.SizeMode.RAW;
      a.trim = false;
      a.spriteFrame = t;
      this.costLabel.string = "" + $2PlantMgr.default.instance().getPlant(e).cost;
      return this;
    }
  }]);
  return p;
}(cc.Component);
cc__decorate([ccp_property(cc.Node)], def_Card.prototype, "bg", undefined);
cc__decorate([ccp_property(cc.Node)], def_Card.prototype, "icon", undefined);
cc__decorate([ccp_property(cc.Node)], def_Card.prototype, "mask", undefined);
cc__decorate([ccp_property(cc.Label)], def_Card.prototype, "costLabel", undefined);
cc__decorate([ccp_property(cc.Node)], def_Card.prototype, "costMask", undefined);
cc__decorate([ccp_property(cc.Node)], def_Card.prototype, "new", undefined);
def_Card = cc__decorate([ccp_ccclass], def_Card);
exports.default = def_Card;